<html>
	<head>
		<meta charset="utf-8">
		<title>日历</title>
	</head>
	<body>
		<center>
		<?php
			//获取时间信息
			//获取年
			$year = isset($_GET['y'])?$_GET['y']:date("Y");
			$month = isset($_GET['m'])?$_GET['m']:date("m");
			// echo $year;
			// echo $month;
			
			//获取需要查看的日期
			$days = date("t",mktime(17,15,15,$month,1,$year));
			$week = date("w",mktime(17,15,15,$month,1,$year));
			echo "<h2>{$year}年{$month}月日历</h2>";
			echo $days;
			echo $week;
			?>
			<br>
			<h2>日历</h2>
			</br>
			<table border="1">
				<tr>
					<th>星期日</th>
					<th>星期一</th>
					<th>星期二</th>
					<th>星期三</th>
					<th>星期四</th>
					<th>星期五</th>
					<th>星期六</th>
				</tr>
				<?php
					//循环输出日期
					$d = 1;
					while( $d<= $days){
						echo "<tr>";
						for($i = 0; $i < 7; $i ++){
							if($d <= $days && ($i >= $week || $d > 1)){
								echo "<td>{$d}</td>";
								$d++;
							}else{
								echo "<td>&nbsp;</td>";
							}
						}
						echo "<tr>";
						
					}
					?>
			</table>
	</body>
</html>